//
//  EduTypeCollectionViewCell.m
//  fp
//
//  Created by xingshuai on 2020/11/14.
//

#import "EduTypeCollectionViewCell.h"

#import "EduBtnBackBiew.h"

@interface EduTypeCollectionViewCell ()

@property (nonatomic, strong) UIImageView *bg_img;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) EduBtnBackBiew *cellSelectView;


@end

@implementation EduTypeCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.contentView.backgroundColor = [UIColor clearColor];
        
//        UIView *bg_view = [[UIView alloc]init];
//        bg_view.backgroundColor = [UIColor clearColor];
////        bg_view.layer.cornerRadius = 5;
////        bg_view.layer.masksToBounds = YES;
//        [self.contentView addSubview:bg_view];
//        [bg_view mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.center.equalTo(self.contentView);
//            make.left.right.equalTo(self.contentView);
//            make.height.mas_offset(40);
//        }];
        
//        self.bg_img = [[UIImageView alloc]init];
//        self.bg_img.backgroundColor = [UIColor clearColor];
//        //self.bg_img.contentMode = UIViewContentModeScaleAspectFill;
//        [bg_view addSubview:self.bg_img];
//        [self.bg_img mas_makeConstraints:^(MASConstraintMaker *make) {
////            make.centerX.equalTo(self.contentView);
////            make.left.bottom.right.equalTo(self.contentView);
////            make.height.mas_offset(50);
//            make.edges.equalTo(bg_view);
//        }];
        
        self.cellSelectView = [[EduBtnBackBiew alloc]init];
        self.cellSelectView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.cellSelectView];
        [self.cellSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
            make.left.right.equalTo(self.contentView);
            make.height.mas_offset(35);
        }];
        
        self.label = [[UILabel alloc]init];
        self.label.textColor = [UIColor colorWithHexString:@"#4E75FF"];
        self.label.backgroundColor = [UIColor clearColor];
        self.label.font = [UIFont pingFangSCWithWeight:FontWeightStyleMedium size:20];
        self.label.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.label];
        [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
            make.height.mas_offset(35);
        }];
    }
    return self;
}

/// 添加四边阴影效果
-(void)addShadowToView:(UIView *)theView withColor:(UIColor *)theColor {
    // 阴影颜色
    theView.layer.shadowColor = theColor.CGColor;
    // 阴影偏移，默认(0, -3)
    theView.layer.shadowOffset = CGSizeMake(0,5);
    // 阴影透明度，默认0
    theView.layer.shadowOpacity = 0.5;
    // 阴影半径，默认3
    theView.layer.shadowRadius = 5;
}


-(void)setModel:(EduCellModel *)model {
    _model = model;
    
}

-(void)creatCellModel:(EduCellModel *)model collectionTag:(NSInteger)tag {
    self.label.text = model.labelStr;
    if (tag == 100) {
        if (model.isSelect) {
            //self.bg_img.image = [UIImage imageNamed:@"edu_bg_tab"];
            self.cellSelectView.backgroundColor = [[UIColor colorWithHexString:@"#4E75FF"] colorWithAlphaComponent:0.8];
            self.label.textColor = [UIColor whiteColor];
        } else {
            //self.bg_img.image = [UIImage imageNamed:@"de"];
            self.cellSelectView.backgroundColor = [UIColor clearColor];
            self.label.textColor = [UIColor colorWithHexString:@"#4E75FF"];
        }
    } else {
        if (model.isSelect) {
            //self.bg_img.image = [UIImage imageNamed:@"edu_bg_bot"];
            self.cellSelectView.backgroundColor = [[UIColor colorWithHexString:@"#4E75FF"] colorWithAlphaComponent:0.8];
            self.label.textColor = [UIColor whiteColor];
        } else {
            //self.bg_img.image = [UIImage imageNamed:@"de"];
            self.cellSelectView.backgroundColor = [UIColor clearColor];
            self.label.textColor = [UIColor colorWithHexString:@"#4E75FF"];
        }
    }
}


@end
